package com.zhicheng.controller;

import com.zhicheng.pojo.Banner;
import com.zhicheng.pojo.result.PageResult;
import com.zhicheng.pojo.result.Result;
import com.zhicheng.service.BannerService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/banner")
public class BannerController {

    @Autowired
    private BannerService bannerService;

    @GetMapping("/list")
    @ApiOperation("分页查询轮播图")
    public Result<PageResult<Banner>> getByUserId(int page, int pageSize){
        PageResult<Banner> pageResult = bannerService.getBanner(page,pageSize);
        return Result.success(pageResult);
    }

    @PostMapping("/add")
    @ApiOperation("添加轮播图信息")
    private Result add(@RequestBody Banner banner) {
        bannerService.addBanner(banner);
        return Result.success();
    }

    @PutMapping("/update")
    @ApiOperation("修改轮播图信息")
    private Result update(@RequestBody Banner banner) {
        bannerService.updateBanner(banner);
        return Result.success();
    }

    @DeleteMapping("/delete")
    @ApiOperation("删除轮播图信息")
    private Result delete(Long id) {
        bannerService.deleteBanner(id);
        return Result.success();
    }


}
